package com.kpf.springcloud.controller;

import com.kpf.springcloud.common.ResultJson;
import com.kpf.springcloud.pojo.PageResult;
import com.kpf.springcloud.service.IKpfTopicCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shiwen
 * @date 2021/3/10
 */
@RestController
public class KpfTopicCommentController {

    @Autowired
    private IKpfTopicCommentService commentService;

    @PostMapping("/comment/commentTopic")
    public ResultJson commentTopic(int topicId, String content){
        commentService.commentTopic(topicId, content);
        return ResultJson.ok();
    }

    @GetMapping("/comment/getCommentListByTopicId")
    public ResultJson<PageResult> getCommentListByTopicId(int topicId, int pageNum, int pageSize) {
        return ResultJson.ok(commentService.getCommentListByTopicId(topicId, pageNum, pageSize));
    }

    @PostMapping("/comment/deleteCommentById")
    public ResultJson deleteCommentById(int commentId) {
        commentService.deleteCommentById(commentId);
        return ResultJson.ok();
    }

    @GetMapping("/comment/getCommentList")
    public ResultJson<PageResult> getCommentList(int pageNum, int pageSize) {
        return ResultJson.ok(commentService.getCommentList(pageNum, pageSize));
    }

}